#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    bool evaluateTree(TreeNode* root) {
        if (root->left == nullptr)  return root->val;
        bool ret1 = evaluateTree(root->left);
        bool ret2 = evaluateTree(root->right);
        if (root->val == 2)  return ret1 | ret2;
        return ret1 & ret2;
    }
};